<template>
  <InputFormula ref="InputFormulaRef" v-bind="InputFormulaOptions" @confirm="handleConfirm">
        <Button type="primary">公式编辑</Button>
  </InputFormula>
</template>
<script setup lang="ts">
import {Button} from 'ant-design-vue';
import InputFormula from './components/InputFormula/index.tsx'
import variableJson from "../conf/variable.json";
import funcJson from "../conf/func.json";
import {nextTick, ref} from "vue";
const InputFormulaRef = ref();
const InputFormulaOptions = {
  //弹窗配置
  modalOptions:{
    title:'公式编辑',
    childTitle:'正在编辑【单行输入】的默认值'
  },
  //表单变量配置
  formOptions:{
    title:'变量',
    treeData:variableJson,
    showParentByNameSpace:['当前表单'],
    isSearch:true
  },
  //函数配置
  funcOptions:{
    title:'函数',
    treeData:funcJson,
    isSearch:true
  },
  //默认提示
  explainOptions:{
    list:undefined
  },
  //编辑器配置
  editorOptions:{
    //内容
    docs:"IF({name}= \"刘德华\",\"18888888888\",{phone})"
  }
}
const handleConfirm = (formula: string)=>{
  nextTick(()=>{
    let result = InputFormulaRef.value.RunFormula({
      name:'李明',
      phone:'17732777485'
    },formula)
    console.log(result)
  })
}
</script>
<style>
body{
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
